package com.example.controller;

import com.example.dto.User;
import com.example.service.HelloService;
import com.example.service.HelloService1;
import com.example.service.RefactorHelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConsumerController {

    @Autowired
    private HelloService1 helloService;

    @Autowired
    private RefactorHelloService refactorHelloService;

    @RequestMapping("hello")
    private String  hello(){
        return  helloService.hello();
    }

    @RequestMapping("feign-consumer2")
    private String  helloConsumer2(){
        StringBuffer sb = new StringBuffer();
        sb.append(helloService.hello()).append("\n");
        sb.append(helloService.hello1("didi")).append("\n");
        sb.append(helloService.hello2("didi",30)).append("\n");
        sb.append(helloService.hello3(new User("didi",30))).append("\n");
        return sb.toString();
    }

    @RequestMapping("feign-consumer3")
    private String  helloConsumer3(){
        StringBuffer sb = new StringBuffer();
        sb.append(refactorHelloService.hello4("MIMI")).append("\n");
        sb.append(refactorHelloService.hello5("MIMI",35)).append("\n");
        sb.append(refactorHelloService.hello6(new User("MIMI",37))).append("\n");
        return sb.toString();
    }
}
